//管理用户数据相关
import {defineStore} from "pinia";
import {ref} from "vue";
import {queryBusinessByIdAPI, queryBusinessByOrderTypeIdAPI} from "@/api/business";

export const useBusinessStore=defineStore('business',()=>{

    const businessList=ref({})
    const BusinessById=ref({})

    const getBusinessById = async (businessId) => {
        const res=await queryBusinessByIdAPI(businessId)
        BusinessById.value=res
        return res

    }
    const listBusinessByOrderTypeId = async (orderTypeId) => {

        const res=await queryBusinessByOrderTypeIdAPI(orderTypeId)

        businessList.value=res
        return res;
    }
    //3. 以对象的格式把state和action return
    return{
        BusinessById,
        businessList,
        getBusinessById,
        listBusinessByOrderTypeId
    }

},{
    persist:true
})
